<template>
  <div>
    <h2>当前求和：{{$store.state.sum}}</h2>
    <h3>当前求和放大10倍后为{{$store.getters.bigSum}}</h3>
    <select v-model.number="n">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
    </select>
    <button @click="increment">+</button>
    <button @click="decrement">-</button>
    <button @click="incrementOdd">当前求和为奇数再加</button>
    <button @click="incrementWait">等{{time}}ms再加</button>
  </div>
</template>

<script>
export default {
  name:'Count',
  data () {
    return {
      n:1,
      time:1500,
    }
  },
  methods: {
    increment(){
      this.$store.commit('INCREMENT', this.n)
    },
    decrement(){
      this.$store.commit('DECREMENT', this.n)
    },
    incrementOdd(){
      this.$store.dispatch('incrementOdd', this.n)
    },
    incrementWait(){
      this.$store.dispatch('incrementWait', {value:this.n,time:this.time})
    },
  }
}
</script>
